/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.seari.semodbus.server;

import com.ghgande.j2mod.modbus.ModbusException;
import com.ghgande.j2mod.modbus.facade.ModbusTCPMaster;
import com.ghgande.j2mod.modbus.slave.ModbusSlave;
import com.ghgande.j2mod.modbus.slave.ModbusSlaveFactory;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Rainbow
 */
public class TcpServer extends ModbusTCPMaster
{
    
    public TcpServer(String addr, int port, int timeout, boolean reconnect)
    {
        super(addr, port, timeout, reconnect);
    }
    
    public static void main(String[] args)
    {
        ModbusSlave modbusSlave;
        try
        {
            modbusSlave = ModbusSlaveFactory.createTCPSlave(502, 3);
            modbusSlave.open();
        } catch (ModbusException ex)
        {
            Logger.getLogger(TcpServer.class.getName()).log(Level.SEVERE, null, ex);
        }
       
    }
    
}
